<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
          <a><cite>首页</cite></a>
          <a><cite>会员管理</cite></a>
          <a><cite>第三方登录</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="AppId" class="layui-form-label">
                    <span class="x-red">*</span>是否开启
                </label>
                <div class="layui-input-block">
                <?php if ($qq_switch['cfg_value']): ?>
                  <input type="checkbox" name="close" lay-skin="switch" title="开关" checked="checked" value="1">
                <?php else: ?>
                  <input type="checkbox" name="close" lay-skin="switch" title="开关" value="1">
                <?php endif ?>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="AppId" class="layui-form-label">
                    <span class="x-red">*</span>AppId
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="AppId" name="AppId" required="" lay-verify="required"
                    autocomplete="off" class="layui-input" value="{$appid}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="Appkey" class="layui-form-label">
                    <span class="x-red">*</span>Appkey
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="Appkey" name="Appkey" required="" lay-verify="required"
                    autocomplete="off" class="layui-input" value="{$appkey}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="returnUrl" class="layui-form-label">
                    <span class="x-red">*</span>回调地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="returnUrl" name="returnUrl" required="" lay-verify="required"
                    autocomplete="off" class="layui-input" value="{$callback}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="save" lay-submit="">
                    保存
                </button>
            </div>
        </form> 
    </div>
    <script>
        layui.use(['element','layer','form'], function(){
            $ = layui.jquery;//jquery
          lement = layui.element();//面包导航
          layer = layui.layer;//弹出层
          form = layui.form()
          

          $('.layui-form-switch').on('click', function () {
              if ($(this).hasClass('layui-form-onswitch')) {
                $('#AppId').removeAttr('disabled');
                $('#Appkey').removeAttr('disabled');
                $('#returnUrl').removeAttr('disabled');
              } else {
                $('#AppId').attr('disabled', true);
                $('#Appkey').attr('disabled', true);
                $('#returnUrl').attr('disabled', true);
              }
          });

          if ($(':input[name="close"]').attr('checked') == 'checked') {
            $('#AppId').removeAttr('disabled');
            $('#Appkey').removeAttr('disabled');
            $('#returnUrl').removeAttr('disabled');
          } else {
            $('#AppId').attr('disabled', true);
            $('#Appkey').attr('disabled', true);
            $('#returnUrl').attr('disabled', true);
          }

         //监听提交
          form.on('submit(save)', function(data){
            //发异步，把数据提交给php
            $.post('{:U('admin/system/qqlogin_edit')}', {data: data.field}, function(response) {
                if (response.type == 1) {
                    layer.msg(response.info, {icon: 6});
                } else if(response.type == 0){
                    layer.msg(response.info, {icon: 5});
                }
            });
            return false;
          });

          });
    </script>
</body>